﻿@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>
@{
    ViewBag.Title = "来料";
    Layout = "~/Views/Shared/FrameWorkList.cshtml";
}

<body>
    <div class="functionHeader" style="width:100%;text-align:left;margin:0px;margin-top:0px;margin-bottom:-64px; border-bottom:2px solid #CCC;">
        <div class="lsider">
            <div class="updowninput btn-group" style="margin-top:10px;">
                <input id="radio11" class="category" name="category" value="来料通知" checked="checked" type="radio"><label for="radio11" class="suffix">来料通知</label><br>
                <input id="radio12" class="category" name="category" value="来料档案" type="radio"><label for="radio12" class="suffix">来料档案</label>
            </div>
            <div class="updowninput" style="width:120px;height:20px;margin-left:10px;">
                <p>来料单位</p>
                <select id="ZSJ_B1_GH_SI" name="F_DutyId" class="form-control">
                    <option value="">==请选择==</option>
                </select>
            </div>
            <div class="updowninput" style="width:120px;height:20px;margin-left:10px;">
                <p>零部件号</p>
                <input type="text" id="txt_FDocuTypeNO" class="form-control required" />
                &nbsp;
            </div>
            <div class="updowninput" style="width:120px;height:20px;margin-left:10px;">
                <p>来料日期</p>
                <input type="text" class="form-control required input-wdatepicker" onfocus="WdatePicker()" />
                &nbsp;
            </div>
            <div class="updowninput" style="width:120px;height:20px;margin-left:10px;">
                <p>凭证编号</p>
                <input type="text" class="form-control required" />
                &nbsp;
            </div>
            <div class="btn-group" style="margin-top:12px;margin-left:10px;">
                &nbsp;
                <a id="btn_search" class="btn btn-primary center-block" onclick=""><span class="glyphicon glyphicon-search"></span>  &nbsp; 查询</a>
            </div>
        </div>

        <div class="rsider">
            <div class="btn-group" style="float:right;margin-top:12px;">
                <a class="btn btn-primary center-block" onclick="$.reload()">  <span class="glyphicon glyphicon-refresh"> </span>&nbsp刷新</a>
                <a class="btn btn-primary center-block" onclick="btn_Add()">   <span class="glyphicon glyphicon-plus">    </span>&nbsp输入</a>
                <a class="btn btn-primary center-block" onclick="btn_Delete()"><span class="glyphicon glyphicon-trash">   </span>&nbsp删除</a>
                <a class="btn btn-primary center-block" onclick="btn_Save()">  <span class="glyphicon glyphicon-plus">    </span>&nbsp存储</a>
                <a class="btn btn-primary center-block" onclick="btn_Excel()"> <span class="glyphicon glyphicon-download"></span>&nbsp导入</a>
                <a class="btn btn-primary center-block" onclick="btn_Excel()"> <span class="glyphicon glyphicon-download"></span>&nbsp导出</a>
            </div>
        </div>
    </div>
    <table class="functionHeader" style="width:97%;text-align:left;margin-bottom:-30px;">
        <tr>
            <td style="width:97%; padding: 1px 1px;margin-top:30px;">
                <div class="updowninput" style="margin-left:20px;width:65px;margin-top:10px;">
                    <p>开票数量</p>
                    <input type="text" id="txtFQuantity_KP" class="form-control required text-right" style="margin-left:60px;width:80px;height:26px;margin-top:-22px;" />
                    &nbsp;
                </div>
                <div class="updowninput" style="margin-left:60px;width:120px;margin-top:10px;">
                    <p>件&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;实际数量</p>
                    <input type="text" id="txtFQuantity" class="form-control required text-right" style="margin-left:108px;width:80px;height:26px;margin-top:-22px;" />
                    &nbsp;
                </div>
                <div class="updowninput" style="margin-left:55px;width:120px;margin-top:10px;">
                    <p>件&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;实际装箱</p>
                    <input type="text" id="txtFFactContent" class="form-control required text-right" style="margin-left:108px;width:80px;height:26px;margin-top:-22px;" />
                    &nbsp;
                </div>
                <div class="updowninput" style="margin-left:48px;width:145px;margin-top:10px;">
                    <p>件/箱&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;标准装箱</p>
                    <input type="text" id="txtFContent" class="form-control required text-right" style="margin-left:128px;width:80px;height:26px;margin-top:-22px;" />
                    &nbsp;
                </div>
                <div class="updowninput" style="margin-left:43px;width:120px;margin-top:10px;">
                    <p>件/箱&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;备注</p>
                    <input type="text" id="txtFAllowEdit" class="form-control required text-right" style="margin-left:102px;width:80px;height:26px;margin-top:-22px;" />
                    &nbsp;
                </div>
                <div class="btn-group" style="margin-left:960px;margin-top:-85px;">
                    <a id="" class="btn btn-primary center-block " onclick="btn_Ok()"><span class="glyphicon glyphicon-ok"></span> 修改</a>
                </div>
            </td>
        </tr>
    </table>
    <div id="grid111">
        <table id="gridList1"></table>
        <div id="gridPager1"></div>
    </div>
    <div id="grid222">
        <table id="gridList2"></table>
        <div id="gridPager2"></div>
    </div>
</body>


<script>
    var rowData = {};
    var index = -1;
    $(function () {
        initControl();
        gridList1();
    });
    function initControl() {
        $('select').bindSelect();
        $('.category').on("click", function () {
            var aa = $("input[type='radio'].category:checked").val();
            if (aa == '来料通知') {
                gridList1();
            } else {
                gridList2();
            }
        });
        $("#ZSJ_B1_GH_SI").bindSelect({
            url: "/BaseData/ZSJ_B1_GH_SI/GetGridJson",
            id: "UnitID",
            text: "UseUnitShortName"
        });
    }

    function btn_Ok() {
        $.each(rowData, function (key, value) {
            rowData[key] = $("#txt" + key).val();
        });
        $("#gridList1").jqGrid('setRowData', index, rowData);
    }
    function btn_Save()
    {
        var postData = [];
        for (var i = 0; i < 10; i++) {
            postData.push(rowData);
        }
        $.submitJson({
            url: "/WareHouse/EnterWareHouse/SubmitForm",
            param: JSON.stringify(postData),
            success: function () {
                $("#gridList1").resetSelection();
                $("#gridList1").trigger("reloadGrid");
            }
        })
    }
    function gridList1() {
        $("#grid111").show();
        $("#grid222").hide();
        var $gridList = $("#gridList1");
        $gridList.dataGridForJson({
            url: "/VBaseData/V_CPK_11_DJ_StoRegister/GetGridJson",
            height: $(window).height() - 170,
            colModel: [
            { label: "来料单位", name: "FHappenCompanyNO", width: 100, align: 'center' },
            { label: "来料单位名称", name: "FHappenCompanyName", width: 130, align: 'center' },
            { label: '入库日期', name: 'FCurDate', width: 80, align: 'center' },
            { label: '零部件号', name: 'FProductionNO', width: 80, align: 'center' },
            { label: '零件名称', name: 'FProductionName ', width: 100, align: 'center' },
            { label: '批次号',   name: 'FBatchNo', width: 80, align: 'center' },
            { label: '开票数量', name: 'FQuantity_KP', width: 60, align: 'center' },
            { label: '实际数量', name: 'FQuantity', width: 60, align: 'center' },
            { label: '容器编号', name: 'FContainerNO', width: 60, align: 'center' },
            { label: '容器名称', name: 'FContainerName', width: 80, align: 'center' },

            { label: '容器数量', name: 'FContainerQuantity', width: 60, align: 'center' },
            { label: '实际装箱', name: 'FFactContent', width: 60, align: 'center' },
            { label: '标准装箱', name: 'FContent', width: 60, align: 'center' },
            { label: '托盘编号', name: 'FPalletNO', width: 60, align: 'center' },
            { label: '托盘数量', name: 'FPalletQuantity', width: 60, align: 'center' },

            { label: '实际容量', name: 'FContainerNO', width: 60, align: 'center' },
            { label: '标准容量', name: 'FContainerQuantity', width: 60, align: 'center' },
            { label: '凭证编号', name: 'FVoucherNo', width: 80, align: 'center' },
            { label: '备注', name: 'FDescription', width: 100, align: 'center' },
            { label: '制造单位', name: 'FProCompanyNO', width: 100, align: 'center' },

            { label: '制造单位名称', name: 'FProCompanyName', width: 120, align: 'center' },
            { label: '零件状态', name: 'FState', width: 60, align: 'center' },
            { label: '输入人员', name: 'FUpdateBy', width: 80, align: 'center' },
            { label: '输入日期', name: 'FUpdateDate', width: 80, align: 'center' },
            { label: '输入时间', name: 'FUpdateTime', width: 100, align: 'center' },
            ],
            pager: "#gridPager1",
            sortname: 'F_DepartmentId asc,F_CreatorTime desc',
            viewrecords: true,
            multiselect: true,
            onSelectRow: function (rowId) {
                rowData = $gridList.jqGrid('getRowData', rowId);
                index = rowId;
                $.each(rowData, function (key, value) {
                    $("#txt" + key).val(value);
                });
            }
        });
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: { keyword: $("#txt_FDocuTypeNO").val() },
            }).trigger('reloadGrid');
        });
    }

    function gridList2() {
        $("#grid111").hide();
        $("#grid222").show();
        var $gridList = $("#gridList2");
        $gridList.dataGrid({
            url: "/WareHouse/V_CPK_12_DJ_StoRegister_Mid/GetGridJson",
            height: $(window).height() - 160,
            colModel: [
            { label: "来料单位", name: "FHappenCompanyNO", width: 100, align: 'center' },
            { label: "来料单位名称", name: "FHappenCompanyName", width: 130, align: 'center' },
            { label: '入库日期', name: 'FCurDate', width: 80, align: 'center' },
            { label: '零部件号', name: 'FProductionNO', width: 80, align: 'center' },
            { label: '零件名称', name: 'FProductionName ', width: 100, align: 'center' },
            { label: '批次号', name: 'FBatchNo', width: 80, align: 'center' },
            { label: '开票数量', name: 'FQuantity_KP', width: 60, align: 'center' },
            { label: '实际数量', name: 'FQuantity', width: 60, align: 'center' },
            { label: '容器编号', name: 'FContainerNO', width: 60, align: 'center' },
            { label: '容器名称', name: 'FContainerName', width: 80, align: 'center' },

            { label: '容器数量', name: 'FContainerQuantity', width: 60, align: 'center' },
            { label: '实际装箱', name: 'FFactContent', width: 60, align: 'center' },
            { label: '标准装箱', name: 'FContent', width: 60, align: 'center' },
            { label: '托盘编号', name: 'FPalletNO', width: 60, align: 'center' },
            { label: '托盘数量', name: 'FPalletQuantity', width: 60, align: 'center' },

            { label: '实际容量', name: 'FContainerNO', width: 60, align: 'center' },
            { label: '标准容量', name: 'FContainerQuantity', width: 60, align: 'center' },
            { label: '凭证编号', name: 'FVoucherNo', width: 80, align: 'center' },
            { label: '备注', name: 'FDescription', width: 100, align: 'center' },
            { label: '制造单位', name: 'FProCompanyNO', width: 100, align: 'center' },

            { label: '制造单位名称', name: 'FProCompanyName', width: 120, align: 'center' },
            { label: '零件状态', name: 'FState', width: 60, align: 'center' },
            { label: '输入人员', name: 'FUpdateBy', width: 80, align: 'center' },
            { label: '输入日期', name: 'FUpdateDate', width: 80, align: 'center' },
            { label: '输入时间', name: 'FUpdateTime', width: 100, align: 'center' },
            ],
            pager: "#gridPager2",
            sortname: 'F_DepartmentId asc,F_CreatorTime desc',
            viewrecords: true,
            multiselect: true,
        });
        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam', {
                postData: { keyword: $("#txt_keyword").val() },
            }).trigger('reloadGrid');

        });
    }
    function btn_Add() {
        $.detailOpen({
            id: "Detail",
            title: "",
            url: "/WareHouse/EnterWareHouse/WareHouseNoticeInput"
        });
    }
    function btn_Modi() {
        $.detailOpen({
            id: "Detail",
            title: "",
            url: "/WareHouse/EnterWareHouse/WareHouseNoticeModi"
        });
    }


    function btn_Delete() {
        alert("确定要删除吗？");//在页面上弹出上联
    }

    function btn_Card() {
        $.detailOpen({
            id: "Detail",
            title: "",
            url: "/WareHouse/EnterWareHouse/WareHouseStorageCard"
        });
    }
    function btn_Excel() {
        $.detailOpen({
            id: "Detail",
            title: "",
            url: "/WareHouse/Export/WareHouseNoticeExcel"
        });
    }
    function btn_Print() {
        $.detailOpen({
            id: "Detail",
            title: "",
            url: "/WareHouse/Print/WareHouseNoticePrint"
        });
    }
</script>

